package 责任链模式例子;

import org.springframework.context.Lifecycle;

/**
 * Created by lilei on 2016/3/24.
 * 处理者
 */
public abstract class Worker {
    protected Worker worker;

    public Worker getWorker() {
        return worker;
    }

    public void setWorker(Worker worker) {
        this.worker = worker;
    }

    //包含是否自己处理以及如何处理的逻辑，自定义的处理放在具体处理者里实现
    public abstract void handle(String name);

    //判断下家存不存在，有可能传给他，让下家处理
    public void next(String name) {
        if(getWorker() != null) {
            getWorker().handle(name);
        }
    }

}
